<template>
  <el-dialog
    v-if="show"
    v-model="dialog"
    title="通过操作确认"
    class="ExamineDetailDialog"
    width="30%"
    :close-on-click-modal="false"
    top="10vh"
    :before-close="handleClose"
  >
    <div>是否通过该用户审核？</div>
    <br>
	<el-select v-model="valueOption" placeholder="请选择分配车辆">
		<el-option
		  v-for="item in options"
		  :key="item.value"
		  :label="item.label"
		  :value="item.value">
		</el-option>
	</el-select>
    <el-select v-model="driverType" placeholder="请选择司机类型">
      <el-option
          v-for="item in driverTypeList"
          :key="item.value"
          :label="item.name"
          :value="item.value">
      </el-option>
    </el-select>
    <br>
    <br>
    <el-button type="success"  @click="approvedBtn()">通过</el-button>
  </el-dialog>
</template>

<script lang="ts" setup>
import { onMounted, reactive, ref, withDefaults } from 'vue'
import api from '@/api/apis/driverExamine'

const driverTypeList=[
  {name:"固定司机",value:1},
  {name:"灵活用工",value:0},
]

interface Props {
  show: boolean
  detailId: string
}
const dialog = ref(true)
const valueOption = ref('')
const driverType = ref('')
const options = reactive([])
const props = withDefaults(defineProps<Props>(), {
  show: false,
  detailId: '',
})
const emit = defineEmits<{
  (event: 'update:show', val: boolean): void
  (event: 'reject', val: string): void
  (event: 'approved', val: string): void
}>()
//弹框关闭
const handleClose = () => {
  emit('update:show', false)
}
// 详情数据
const detailData = ref()
onMounted(() => {
  getDetailApi()
})
//获取详情
const getDetailApi = async () => {
  let { data } = await api.getUndistributedCar()
  console.log("--------------------------------------------",data)
  if (data.code == 200) {
    data.data.forEach((item,index)=>{
      options.push({
        value: item.carNo,
        label: item.carNo
      })
    })
    console.log(data.data)
    detailData.value = data.data
  }
}
//通过
const approvedBtn = () => {
  console.log('000',detailData.value.id)
  var v = ''
  options.forEach((item)=> {
    if(item.value == valueOption.value){
      v=item.value
    }
  })
  console.log('xxx',driverType.value)

  emit('approved', {carNo:v, driverType:driverType.value})
}
</script>

<style lang="scss">
.ExamineDetailDialog {
  .el-dialog__body {
    padding: 0px 20px 10px;
  }
}
</style>
